<?php
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : keyword.class.php   FILE_PATH : E:\www\\classes\application\keyword.class.php
 * 搜索关键词管理
 *
 * @copyright Copyright (c) 2007 - 2007 www.shopnc.net 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Thu Mar 06 10:57:14 CST 2008
 */

class KeywordClass extends FrameWork {
	/**
	 * 取关键词表内容
	 * @author     
	 * @param  
	 * @return int/bool/object/array
	 */
	function getKeywordList($condition,&$obj_page){
		$conditionstr = $this->_conditionSearch($condition);
		$keyword_array = $GLOBALS['db']->GetList($conditionstr, $obj_page, "keyword");
		return $keyword_array;
	}
	
	/**
	 * 构造检索条件
	 * @author     
	 * @param  
	 * @return 
	 */
	function _conditionSearch($condition){
		$conditionstr = '';
		
		/*ID*/
		if ($condition['id'] != "") {
			$conditionstr .= " and keyword_id='" . $condition['id'] . "'";
		}
		/*关键词名称*/
		if ($condition['name'] != "") {
			$conditionstr .= " and keyword_name='" . $condition['name'] . "'";
		}
		/*关键词名称*/
		if ($condition['like_name'] != "") {
			$conditionstr .= " and keyword_name like '%" . $condition['like_name'] . "%'";
		}
		/*前台是否显示*/
		if ($condition['keyword_display'] != '') {
			$conditionstr .= " and keyword_display='" . $condition['keyword_display'] . "'";
		}
		if ($condition['order_by'] != "") {
			$conditionstr .= " order by ". $condition['order_by'];
		}
		if ($condition['order'] == 1) {
			$conditionstr .= " order by keyword_sort asc ";
		}
		if ($condition['sort'] != "") {
			$conditionstr .= " desc";
		}
		return $conditionstr;
	}
	
	
	/**
	 * 保存新增关键词
	 * @author     
	 * @param  
	 * @return bool
	 */
	function addKeyword($input_param){
		if (is_array($input_param)) {
			$value_array = array();
			foreach ($input_param as $k => $v){
				if ($v != ''){
					$value_array[$k] = $v;
				}
			}
		}
		return $GLOBALS['db']->InsertRow($value_array,"keyword","keyword_id");
	}
	
	/**
	 * 取指定信息
	 * @author     
	 * @param  
	 * @return array
	 */
	function getOneKeyword($id){
		if (intval($id) > 0) {
			return $GLOBALS['db']->GetOneRow($id,'keyword','keyword_id');
		}
	}
	
	/**
	 * 更新
	 * @author     
	 * @param  
	 * @return bool
	 */
	function updateKeyword($input_param){
		if(intval($input_param['keyword_id']) > 0){
			if (is_array($input_param)){
				$value_array = array();
				foreach ($input_param as $k => $v){
					if ($v != ''){
						$value_array[$k] = $v;
					}
				}
			}
			if ($GLOBALS['db']->UpdateRow(intval($value_array['keyword_id']),$value_array, 'keyword', 'keyword_id')){
				return true;
			}else{
				return false;
			}
		}else {
			return false;
		}
	}
	
	/**
	 * 删除
	 * @author     
	 * @param  
	 * @return bool
	 */
	function delKeyword($id){
		if (intval($id) > 0) {
			$GLOBALS['db']->DeleOneRow(intval($id),'keyword','keyword_id');
		}
		return true;
	}
}
?>